package BinaryTree01;

import java.util.List;

public class Test {
    public static void main(String[] args) {
        //创建一个二叉树的对象
        BinaryTree binaryTree = new BinaryTree();
        BinaryTree.TreeNode root = binaryTree.createTree();
        //调用前序遍历方法,把结果存到ret中~

        List<BinaryTree.TreeNode> ret = binaryTree.preOrder(root);

        //使用for循环遍历打印ret
        for (BinaryTree.TreeNode x : ret) {
            System.out.print(x.val + " ");
        }
        System.out.println();
        System.out.println("===========");
        int size = binaryTree.sizeNode(root);
        System.out.println("遍历二叉树之后,二叉树的总结点个数是" + size);

        System.out.println("===========");

        int size02 = binaryTree.sizeNode02(root);
        System.out.println("计算左右子树之后的,二叉树的总结点个数是" + size02);
        System.out.println();
        System.out.println("==========");
        System.out.println();
        int leafSize = binaryTree.getLeafSize02(root);
        System.out.println("这个二叉树的叶子结点的个数是" + leafSize);

        System.out.println();
        System.out.println("=======================");
        int leafSize02 = binaryTree.getLeafSize02(root);
        System.out.println("通过计算左右子树的叶子结点来计算总的叶子结点的个数是" + leafSize02);

        int Kcount = binaryTree.getKLevelCount(root,2);
        System.out.println("第二层有" + Kcount +" 个节点");


        System.out.println();
        System.out.println("=====================");
        int height = binaryTree.getHeight(root);
        System.out.println("树的高度是" + height);
    }

















        /*//调用中序遍历方法
        binaryTree.inOrder(root);
        System.out.println();
        System.out.println("===========");
        //最后调用后序遍历方法
        binaryTree.postOrder(root);*/


















        /*List<BinaryTree.TreeNode> ret = binaryTree.preOrder02(root);
        for(BinaryTree.TreeNode x : ret){
            System.out.print(x.val + " ");
        }
        System.out.println("===");*/


}
